$(document).ready(function()
{
    $('#main-nav>li:has(ul)').each(function() {
        var $this = $(this);
        $('<span>').html('&darr;').css({
            position: 'absolute',
            right: '5px',
            bottom: '5px',
            color: '#fff'
        }).appendTo($this);

        $this.hover(
            function()
            {
                var $target = $this.children('ul');
                if ($target.queue().length <= 1) {
                    $target.slideDown(600);
                }
            },
            function()
            {
                var $target = $this.children('ul');
                $target.fadeOut(700);
            }
        );
    });

    // Cấp 2
    $('#main-nav ul li:has(ul)').each(function () {
        var $this = $(this);
        $('<span>').html('&rarr;').css({
            position: 'absolute',
            right: '5px',
            bottom: '5px',
            color: '#fff'
        }).appendTo($this);

        $this.hover(
            function()
            {
                var $target = $this.children('ul').css({
                    left: $this.width(),
                    top: 0
                });
                if ($target.queue().length <= 1) {
                    $target.slideDown(600);
                }
            },
            function()
            {
                var $target = $this.children('ul');
                $target.fadeOut(700);
            }
        );
    });

    $('a.no-click').click(function(event) {
        event.preventDefault();
    })
});